package com.penglecode.dp.creational.factory.general;

import com.penglecode.dp.creational.MailSender;
import com.penglecode.dp.creational.Sender;
import com.penglecode.dp.creational.SmsSender;
/**
 * 普通工厂模式(也称简单工厂方法模式)
 * 
 * @author pengpeng
 * @date 2013-5-14上午10:13:35
 * @version 1.0
 * @see [相关类/方法]
 * @since [产品/模块版本]
 */
public class SimpleMethodFactory {

	public Sender createSender(String messageType){
		if("mail".equals(messageType)){
			return new MailSender();
		}else if("sms".equals(messageType)){
			return new SmsSender();
		}else {
			return null;
		}
	}
	
	public static void main(String[] args) {
		SimpleMethodFactory factory = new SimpleMethodFactory();
		Sender sender = factory.createSender("mail");
		sender.sendMessage();
	}
	
}
